//方法一：库函数qsort
#include <iostream>
using namespace std;

int cmp(const void *pa, const void *pb){
    return *(int*)pa - *(int*)pb;
}

int main() {

    int arr[6] = { 0 };
    int len = sizeof(arr) / sizeof(int);
    
    for (int i = 0; i < len; i++) {
        cin >> arr[i];
    }
    
    // write your code here......
    qsort(arr, 6, sizeof(int), cmp);

    for (int i = 0; i < len; i++) {
        cout << arr[i] << " ";
    }
    return 0;
}

//方法二：冒泡排序
#include <iostream>
using namespace std;

int main() {

    int arr[6] = { 0 };
    int len = sizeof(arr) / sizeof(int);
    
    for (int i = 0; i < len; i++) {
        cin >> arr[i];
    }
    
    // write your code here......
   for(int i = 0; i < len; i++){
        for(int j = len - 1; j > i; j--){
            if(arr[i] > arr[j]){
                int temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
            }
        }
   }
    for(int i = 0; i < len; i++){
        cout << arr[i] << " ";
    }

    return 0;
}

//方法三：直接插入排序
#include <iostream>
using namespace std;

int main() {

    int arr[6] = { 0 };
    int len = sizeof(arr) / sizeof(int);
    
    for (int i = 0; i < len; i++) {
        cin >> arr[i];
    }
    
    // write your code here......
    for(int i = 0; i < len - 1; i++){
        int end = i;
        int temp = arr[end + 1];
        while(end >= 0){
            if(arr[end] > temp){
                arr[end + 1] = arr[end];
                end -= 1;
            }
            else{
                break;
            }
        }
        arr[end + 1] = temp;
    }
    for(int i = 0; i < len; i++){
        cout << arr[i] << " ";
    }
    return 0;
}

//方法四：希尔排序
#include <iostream>
using namespace std;

int main() {

    int arr[6] = { 0 };
    int len = sizeof(arr) / sizeof(int);

    for (int i = 0; i < len; i++) {
        cin >> arr[i];
    }

    // write your code here......
    int gap = len;
    while (gap > 1) {
        gap = gap / 3 + 1;
        for (int i = 0; i < len - gap; i++) {
            int end = i;
            int temp = arr[end + gap];
            while (end >= 0) {
                if (arr[end] > temp) {
                    arr[end + gap] = arr[end];
                    end -= gap;
                } else {
                    break;
                }
            }
            arr[end + gap] = temp;
        }
    }

    for (int i = 0; i < len; i++) {
        cout << arr[i] << " ";
    }
    return 0;
}